﻿
Imports System.Data.OleDb
Public Class VeDAO
    Public Function Insert(ByVal tmp As VeDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "insert into VE(MaSuatChieu,GiaVeBan,IDThanhVien, VeDat, SoHang, SoDay) values (@MaSuatChieu,@GiaVeBan,@IDThanhVien, @VeDat, @SoHang, @SoDay)"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1, para2, para3, para4, para5, para6 As OleDbParameter
        para1 = New OleDbParameter("@MaSuatChieu", tmp.MaSuatChieu)
        cmd.Parameters.Add(para1)
        para2 = New OleDbParameter("@GiaVeBan", tmp.GiaVeBan)
        cmd.Parameters.Add(para2)
        para3 = New OleDbParameter("@IDThanhVien", tmp.IDThanhVien)
        cmd.Parameters.Add(para3)
        para4 = New OleDbParameter("@VeDat", tmp.VeDat)
        cmd.Parameters.Add(para4)
        para5 = New OleDbParameter("@SoHang", tmp.SoHang)
        cmd.Parameters.Add(para5)
        para6 = New OleDbParameter("@SoDay", tmp.SoDay)
        cmd.Parameters.Add(para6)
        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function

    Public Function Update(ByVal tmp As VeDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "update VE set MaSuatChieu=@MaSuatChieu,GiaVeBan=@GiaVeBan,IDThanhVien=@IDThanhVien,VeDat=@VeDat, SoHang =@SoHang, SoDay = @SoDay where MaVe=@MaVe"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1, para2, para3, para4, para5, para6, para7 As OleDbParameter
        para1 = New OleDbParameter("@MaSuatChieu", tmp.MaSuatChieu)
        cmd.Parameters.Add(para1)
        para2 = New OleDbParameter("@GiaVeBan", tmp.GiaVeBan)
        cmd.Parameters.Add(para2)
        para3 = New OleDbParameter("@IDThanhVien", tmp.IDThanhVien)
        cmd.Parameters.Add(para3)
        para4 = New OleDbParameter("@VeDat", tmp.VeDat)
        cmd.Parameters.Add(para4)
        para5 = New OleDbParameter("@SoHang", tmp.SoHang)
        cmd.Parameters.Add(para5)
        para6 = New OleDbParameter("@SoDay", tmp.SoDay)
        cmd.Parameters.Add(para6)
        para7 = New OleDbParameter("@MaVe", tmp.MaVe)
        cmd.Parameters.Add(para7)
        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function

    Public Function Delete(ByVal tmp As VeDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "delete from VE where MaVe=@MaVe"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1 As OleDbParameter
        para1 = New OleDbParameter("@MaVe", tmp.MaVe)
        cmd.Parameters.Add(para1)

        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function

End Class
